#pragma once

#include<iostream>
#include<cassert>
using namespace std;

namespace bit
{
	#define npos -1
	typedef char* iterator;
	typedef const char* const_iterator;
	class string
	{
	public:
		string(const char* str = "");
		string(const string& str);

		const char* c_str()const;

		string& operator=(const string& str);

		size_t size()const;

		char& operator[](size_t pos);
		const char& operator[](size_t pos)const;

		iterator begin();
		const_iterator begin()const;

		iterator end();
		const_iterator end()const;

		size_t capacity()const;

		void reserve(size_t n = 0);

		string& push_back(char c);

		string& append(const string& str);

		string& insert(size_t pos,const string& str,size_t st = 0,size_t len = npos);
		string& insert(size_t pos, char c);

		void erase(size_t pos = 0, size_t len = npos);

		size_t find(const string& st, size_t pos = 0)const;

		size_t find(char c, size_t pos = 0)const;

		void swap(string& s1);

		string substr(size_t pos, size_t len = npos)const;

		string& operator+=(const string& s1);
		string& operator+=(char c);


		bool operator>(const string& s)const;
		bool operator<(const string& s)const;
		bool operator<=(const string& s) const;
		bool operator>=(const string& s) const;
		bool operator==(const string& s) const;
		bool operator!=(const string& s) const;

		void clear();

		~string();

	private:
		size_t _size;
		size_t _capacity;
		char* _str;
	};

	istream& operator>> (istream& is, string& str);
	ostream& operator<< (ostream& os, const string& str);

	void swap(string& s1, string& s2);
}